package cn.yyljlyy.blog.frontend.service.impl;

import cn.yyljlyy.blog.frontend.dao.ContextDao;
import cn.yyljlyy.blog.frontend.entity.Content;
import cn.yyljlyy.blog.frontend.service.ContextService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

/**
 * @function: cn.yyljlyy.blog.frontend.service.impl
 * @author: LiJian
 * @data: 2016年11月20日18：32.
 */
@Service("contextService")
public class ContextServiceImpl implements ContextService {
    @Autowired
    private ContextDao contextDao;

    @Override
    public Page<Content> getIndexList() {
        Sort sort = new Sort(Sort.Direction.DESC, "id");
        Pageable pageable = new PageRequest(0, 10, sort);
        return contextDao.findAll(pageable);
    }

    @Override
    public Integer countByModuleAndStatus(String module, String status) {
        return contextDao.countByModuleAndStatus(module,status);
    }
}
